Socket
Socket
Sign inDemoInstall

find-parent-dir

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

find-parent-dir

Finds the first parent directory that contains a given file or directory.


Version published
Weekly downloads
344K
decreased by-16.02%
Maintainers
1
Weekly downloads
 
Created

What is find-parent-dir?

The find-parent-dir npm package is a utility for finding the parent directory of a given directory that contains a specific file or directory. It is useful for tasks such as locating configuration files or project root directories in a file system hierarchy.

What are find-parent-dir's main functionalities?

Find Parent Directory Containing a Specific File

This feature allows you to find the parent directory that contains a specific file, such as 'package.json'. The code sample demonstrates how to use the findParentDir function to locate the parent directory of the current directory (__dirname) that contains 'package.json'.

const findParentDir = require('find-parent-dir');

findParentDir(__dirname, 'package.json', (err, dir) => {
  if (err) {
    console.error(err);
  } else {
    console.log('Parent directory containing package.json:', dir);
  }
});

Find Parent Directory Containing a Specific Directory

This feature allows you to find the parent directory that contains a specific directory, such as 'node_modules'. The code sample demonstrates how to use the findParentDir function to locate the parent directory of the current directory (__dirname) that contains 'node_modules'.

const findParentDir = require('find-parent-dir');

findParentDir(__dirname, 'node_modules', (err, dir) => {
  if (err) {
    console.error(err);
  } else {
    console.log('Parent directory containing node_modules:', dir);
  }
});

Other packages similar to find-parent-dir

Keywords

FAQs

Package last updated on 14 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc